package com.it.io;

import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;

public class IteratorIOSequence<E> extends AbstractIOSequence<Iterator<E>, E> {

	List<E> result;

	@Override
	public void initInput(Iterator<E> input) {
		this.input = input;
	}

	@Override
	public boolean hasInput() {
		return input.hasNext();
	}

	@Override
	public E input() {
		inputIndex++;
		return input.next();
	}

	@Override
	public void initOutput(int size) {
		result = new ArrayList<>(size);
	}

	@Override
	public void output(E e) {
		result.add(e);
		outputIndex++;
	}

	@Override
	public Iterator<E> finish() {
		return result.iterator();
	}
	
	
}